package basic.comparableAndComparator;

import java.util.Objects;

/**
 * @Description: TODO 用于比较的对象
 * @Author: wzj
 * @Date: 2020/4/11 9:24
 */
public class CompareObj {
    private int i;
    private String str;

    public CompareObj() {
    }

    public CompareObj(int i, String str) {
        this.i = i;
        this.str = str;
    }

    public int getI() {
        return i;
    }

    public void setI(int i) {
        this.i = i;
    }

    public String getStr() {
        return str;
    }

    public void setStr(String str) {
        this.str = str;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CompareObj that = (CompareObj) o;
        return i == that.i &&
                Objects.equals(str, that.str);
    }

    @Override
    public int hashCode() {

        return Objects.hash(i, str);
    }

    @Override
    public String toString() {
        return "CompareObj{" +
                "i=" + i +
                ", str='" + str + '\'' +
                '}';
    }
}
